package org.blame.orderservice.controller;

import org.blame.orderservice.model.UserInfo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/createOrder")
    public String createOrder(){
        String orderId= UUID.randomUUID().toString();
        rabbitTemplate.convertAndSend("","queue.build","下单成功"+orderId);
        return "下单成功";
    }

    @RequestMapping("/createOrder1")
    public String createOrder1(){
        String orderId= UUID.randomUUID().toString();
        UserInfo userInfo=new UserInfo();
        userInfo.setMessageId(orderId);
        userInfo.setMessageId("发送消息成功");
        rabbitTemplate.convertAndSend("","queue.build",userInfo);
        return "下单成功";
    }
}
